.class public Lcom/inmobi/commons/internal/ThinICE;
.super Ljava/lang/Object;
.source "ThinICE.java"


# static fields
.field static a:Ljava/lang/Object;

.field private static b:Z

.field private static c:Lcom/inmobi/commons/thinICE/icedatacollector/ThinICEListener;


# direct methods
.method static constructor <clinit>()V
    .locals 1

    .prologue
    .line 24
    const/4 v0, 0x0

    sput-boolean v0, Lcom/inmobi/commons/internal/ThinICE;->b:Z

    .line 26
    new-instance v0, Lcom/inmobi/commons/internal/a;

    invoke-direct {v0}, Lcom/inmobi/commons/internal/a;-><init>()V

    sput-object v0, Lcom/inmobi/commons/internal/ThinICE;->c:Lcom/inmobi/commons/thinICE/icedatacollector/ThinICEListener;

    .line 168
    const/4 v0, 0x0

    sput-object v0, Lcom/inmobi/commons/internal/ThinICE;->a:Ljava/lang/Object;

    return-void
.end method

.method public constructor <init>()V
    .locals 0

    .prologue
    .line 22
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    return-void
.end method

.method static synthetic a()V
    .locals 0

    .prologue
    .line 22
    invoke-static {}, Lcom/inmobi/commons/internal/ThinICE;->b()V

    return-void
.end method

.method private static a(Landroid/app/Activity;)V
    .locals 4
    .parameter
    .annotation build Landroid/annotation/SuppressLint;
        value = {
            "NewApi"
        }
    .end annotation

    .prologue
    .line 74
    sget-boolean v0, Lcom/inmobi/commons/internal/ThinICE;->b:Z

    if-nez v0, :cond_0

    if-nez p0, :cond_0

    .line 75
    new-instance v0, Ljava/lang/NullPointerException;

    invoke-direct {v0}, Ljava/lang/NullPointerException;-><init>()V

    throw v0

    .line 77
    :cond_0
    sget-boolean v0, Lcom/inmobi/commons/internal/ThinICE;->b:Z

    if-nez v0, :cond_1

    .line 78
    sget v0, Landroid/os/Build$VERSION;->SDK_INT:I

    const/16 v1, 0xe

    if-lt v0, v1, :cond_2

    .line 79
    new-instance v0, Lcom/inmobi/commons/internal/ThinICE$b;

    invoke-direct {v0}, Lcom/inmobi/commons/internal/ThinICE$b;-><init>()V

    sput-object v0, Lcom/inmobi/commons/internal/ThinICE;->a:Ljava/lang/Object;

    .line 106
    invoke-virtual {p0}, Landroid/app/Activity;->getApplication()Landroid/app/Application;

    move-result-object v1

    sget-object v0, Lcom/inmobi/commons/internal/ThinICE;->a:Ljava/lang/Object;

    check-cast v0, Landroid/app/Application$ActivityLifecycleCallbacks;

    invoke-virtual {v1, v0}, Landroid/app/Application;->registerActivityLifecycleCallbacks(Landroid/app/Application$ActivityLifecycleCallbacks;)V

    .line 107
    invoke-virtual {p0}, Landroid/app/Activity;->getApplicationContext()Landroid/content/Context;

    move-result-object v0

    invoke-static {v0}, Lcom/inmobi/commons/thinICE/icedatacollector/IceDataCollector;->start(Landroid/content/Context;)V

    .line 112
    :goto_0
    const/4 v0, 0x1

    sput-boolean v0, Lcom/inmobi/commons/internal/ThinICE;->b:Z

    .line 116
    :cond_1
    :try_start_0
    const-string v0, "commons"

    invoke-static {}, Lcom/inmobi/commons/internal/InternalSDKUtil;->getContext()Landroid/content/Context;

    move-result-object v1

    const/4 v2, 0x0

    const/4 v3, 0x0

    invoke-static {v0, v1, v2, v3}, Lcom/inmobi/commons/cache/CacheController;->getConfig(Ljava/lang/String;Landroid/content/Context;Ljava/util/Map;Lcom/inmobi/commons/cache/CacheController$Validator;)Lcom/inmobi/commons/cache/ProductConfig;
    :try_end_0
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0

    .line 121
    :goto_1
    return-void

    .line 110
    :cond_2
    sget-object v0, Lcom/inmobi/commons/internal/ThinICE;->c:Lcom/inmobi/commons/thinICE/icedatacollector/ThinICEListener;

    invoke-static {v0}, Lcom/inmobi/commons/thinICE/icedatacollector/IceDataCollector;->setListener(Lcom/inmobi/commons/thinICE/icedatacollector/ThinICEListener;)V

    goto :goto_0

    .line 118
    :catch_0
    move-exception v0

    goto :goto_1
.end method

.method static a(Lcom/inmobi/commons/internal/ThinICEConfig;)V
    .locals 5
    .parameter

    .prologue
    const-wide/16 v3, 0x3e8

    .line 35
    if-eqz p0, :cond_0

    .line 36
    new-instance v0, Lcom/inmobi/commons/thinICE/icedatacollector/ThinICEConfigSettings;

    invoke-direct {v0}, Lcom/inmobi/commons/thinICE/icedatacollector/ThinICEConfigSettings;-><init>()V

    .line 37
    iget-boolean v1, p0, Lcom/inmobi/commons/internal/ThinICEConfig;->h:Z

    invoke-virtual {v0, v1}, Lcom/inmobi/commons/thinICE/icedatacollector/ThinICEConfigSettings;->setEnabled(Z)Lcom/inmobi/commons/thinICE/icedatacollector/ThinICEConfigSettings;

    .line 38
    iget-boolean v1, p0, Lcom/inmobi/commons/internal/ThinICEConfig;->j:Z

    invoke-virtual {v0, v1}, Lcom/inmobi/commons/thinICE/icedatacollector/ThinICEConfigSettings;->setSampleCellEnabled(Z)Lcom/inmobi/commons/thinICE/icedatacollector/ThinICEConfigSettings;

    .line 39
    iget-boolean v1, p0, Lcom/inmobi/commons/internal/ThinICEConfig;->i:Z

    invoke-virtual {v0, v1}, Lcom/inmobi/commons/thinICE/icedatacollector/ThinICEConfigSettings;->setSampleCellOperatorEnabled(Z)Lcom/inmobi/commons/thinICE/icedatacollector/ThinICEConfigSettings;

    .line 40
    iget-boolean v1, p0, Lcom/inmobi/commons/internal/ThinICEConfig;->k:Z

    invoke-virtual {v0, v1}, Lcom/inmobi/commons/thinICE/icedatacollector/ThinICEConfigSettings;->setSampleConnectedWifiEnabled(Z)Lcom/inmobi/commons/thinICE/icedatacollector/ThinICEConfigSettings;

    .line 41
    iget v1, p0, Lcom/inmobi/commons/internal/ThinICEConfig;->e:I

    invoke-virtual {v0, v1}, Lcom/inmobi/commons/thinICE/icedatacollector/ThinICEConfigSettings;->setSampleHistorySize(I)Lcom/inmobi/commons/thinICE/icedatacollector/ThinICEConfigSettings;

    .line 42
    iget-wide v1, p0, Lcom/inmobi/commons/internal/ThinICEConfig;->a:J

    mul-long/2addr v1, v3

    invoke-virtual {v0, v1, v2}, Lcom/inmobi/commons/thinICE/icedatacollector/ThinICEConfigSettings;->setSampleInterval(J)Lcom/inmobi/commons/thinICE/icedatacollector/ThinICEConfigSettings;

    .line 43
    iget-boolean v1, p0, Lcom/inmobi/commons/internal/ThinICEConfig;->m:Z

    invoke-virtual {v0, v1}, Lcom/inmobi/commons/thinICE/icedatacollector/ThinICEConfigSettings;->setSampleLocationEnabled(Z)Lcom/inmobi/commons/thinICE/icedatacollector/ThinICEConfigSettings;

    .line 44
    iget-boolean v1, p0, Lcom/inmobi/commons/internal/ThinICEConfig;->l:Z

    invoke-virtual {v0, v1}, Lcom/inmobi/commons/thinICE/icedatacollector/ThinICEConfigSettings;->setSampleVisibleWifiEnabled(Z)Lcom/inmobi/commons/thinICE/icedatacollector/ThinICEConfigSettings;

    .line 45
    iget-wide v1, p0, Lcom/inmobi/commons/internal/ThinICEConfig;->b:J

    mul-long/2addr v1, v3

    invoke-virtual {v0, v1, v2}, Lcom/inmobi/commons/thinICE/icedatacollector/ThinICEConfigSettings;->setStopRequestTimeout(J)Lcom/inmobi/commons/thinICE/icedatacollector/ThinICEConfigSettings;

    .line 46
    iget v1, p0, Lcom/inmobi/commons/internal/ThinICEConfig;->f:I

    invoke-virtual {v0, v1}, Lcom/inmobi/commons/thinICE/icedatacollector/ThinICEConfigSettings;->setWifiFlags(I)Lcom/inmobi/commons/thinICE/icedatacollector/ThinICEConfigSettings;

    .line 47
    iget v1, p0, Lcom/inmobi/commons/internal/ThinICEConfig;->g:I

    invoke-virtual {v0, v1}, Lcom/inmobi/commons/thinICE/icedatacollector/ThinICEConfigSettings;->setCellOpFlags(I)Lcom/inmobi/commons/thinICE/icedatacollector/ThinICEConfigSettings;

    .line 49
    invoke-static {v0}, Lcom/inmobi/commons/thinICE/icedatacollector/IceDataCollector;->setConfig(Lcom/inmobi/commons/thinICE/icedatacollector/ThinICEConfigSettings;)V

    .line 51
    :cond_0
    return-void
.end method

.method static synthetic a(Ljava/lang/String;)V
    .locals 0
    .parameter
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/io/IOException;
        }
    .end annotation

    .prologue
    .line 22
    invoke-static {p0}, Lcom/inmobi/commons/internal/ThinICE;->b(Ljava/lang/String;)V

    return-void
.end method

.method static synthetic a(Ljava/util/List;)V
    .locals 0
    .parameter

    .prologue
    .line 22
    invoke-static {p0}, Lcom/inmobi/commons/internal/ThinICE;->b(Ljava/util/List;)V

    return-void
.end method

.method private static b()V
    .locals 1

    .prologue
    .line 67
    invoke-static {}, Lcom/inmobi/commons/thinICE/icedatacollector/IceDataCollector;->getData()Ljava/util/List;

    move-result-object v0

    .line 68
    invoke-static {}, Lcom/inmobi/commons/thinICE/icedatacollector/IceDataCollector;->stop()V

    .line 69
    invoke-static {v0}, Lcom/inmobi/commons/internal/ThinICE;->b(Ljava/util/List;)V

    .line 70
    return-void
.end method

.method private static b(Ljava/lang/String;)V
    .locals 3
    .parameter
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/io/IOException;
        }
    .end annotation

    .prologue
    .line 154
    new-instance v0, Ljava/net/URL;

    sget-object v1, Lcom/inmobi/commons/internal/InternalSDKUtil;->a:Lcom/inmobi/commons/internal/CommonsConfig;

    invoke-virtual {v1}, Lcom/inmobi/commons/internal/CommonsConfig;->getTic()Lcom/inmobi/commons/internal/ThinICEConfig;

    move-result-object v1

    iget-object v1, v1, Lcom/inmobi/commons/internal/ThinICEConfig;->n:Ljava/lang/String;

    invoke-direct {v0, v1}, Ljava/net/URL;-><init>(Ljava/lang/String;)V

    .line 155
    invoke-virtual {v0}, Ljava/net/URL;->openConnection()Ljava/net/URLConnection;

    move-result-object v0

    check-cast v0, Ljava/net/HttpURLConnection;

    .line 157
    const/4 v1, 0x1

    invoke-virtual {v0, v1}, Ljava/net/HttpURLConnection;->setDoOutput(Z)V

    .line 158
    const/4 v1, 0x0

    invoke-virtual {v0, v1}, Ljava/net/HttpURLConnection;->setDoInput(Z)V

    .line 160
    new-instance v1, Ljava/io/OutputStreamWriter;

    invoke-virtual {v0}, Ljava/net/HttpURLConnection;->getOutputStream()Ljava/io/OutputStream;

    move-result-object v2

    invoke-direct {v1, v2}, Ljava/io/OutputStreamWriter;-><init>(Ljava/io/OutputStream;)V

    .line 162
    invoke-virtual {v1, p0}, Ljava/io/OutputStreamWriter;->write(Ljava/lang/String;)V

    .line 163
    invoke-virtual {v1}, Ljava/io/OutputStreamWriter;->flush()V

    .line 164
    invoke-virtual {v1}, Ljava/io/OutputStreamWriter;->close()V

    .line 165
    invoke-virtual {v0}, Ljava/net/HttpURLConnection;->getResponseCode()I

    .line 166
    return-void
.end method

.method private static b(Ljava/util/List;)V
    .locals 5
    .parameter
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "(",
            "Ljava/util/List",
            "<",
            "Lcom/inmobi/commons/thinICE/icedatacollector/Sample;",
            ">;)V"
        }
    .end annotation

    .prologue
    .line 124
    invoke-interface {p0}, Ljava/util/List;->size()I

    move-result v0

    if-nez v0, :cond_0

    .line 125
    const-string v0, "IMCOMMONS_3.7.0"

    const-string v1, "No ThinICE data is collected. NoOp."

    invoke-static {v0, v1}, Lcom/inmobi/commons/internal/Log;->internal(Ljava/lang/String;Ljava/lang/String;)V

    .line 151
    :goto_0
    return-void

    .line 128
    :cond_0
    sget-object v0, Lcom/inmobi/commons/internal/InternalSDKUtil;->a:Lcom/inmobi/commons/internal/CommonsConfig;

    invoke-virtual {v0}, Lcom/inmobi/commons/internal/CommonsConfig;->getTic()Lcom/inmobi/commons/internal/ThinICEConfig;

    move-result-object v0

    iget-boolean v0, v0, Lcom/inmobi/commons/internal/ThinICEConfig;->h:Z

    if-nez v0, :cond_1

    .line 129
    const-string v0, "IMCOMMONS_3.7.0"

    const-string v1, "ThisICE disabled. Not sending data. NoOp."

    invoke-static {v0, v1}, Lcom/inmobi/commons/internal/Log;->internal(Ljava/lang/String;Ljava/lang/String;)V

    goto :goto_0

    .line 132
    :cond_1
    new-instance v0, Lcom/inmobi/commons/cache/RetryMechanism;

    sget-object v1, Lcom/inmobi/commons/internal/InternalSDKUtil;->a:Lcom/inmobi/commons/internal/CommonsConfig;

    invoke-virtual {v1}, Lcom/inmobi/commons/internal/CommonsConfig;->getTic()Lcom/inmobi/commons/internal/ThinICEConfig;

    move-result-object v1

    iget-wide v1, v1, Lcom/inmobi/commons/internal/ThinICEConfig;->d:J

    long-to-int v1, v1

    sget-object v2, Lcom/inmobi/commons/internal/InternalSDKUtil;->a:Lcom/inmobi/commons/internal/CommonsConfig;

    invoke-virtual {v2}, Lcom/inmobi/commons/internal/CommonsConfig;->getTic()Lcom/inmobi/commons/internal/ThinICEConfig;

    move-result-object v2

    iget-wide v2, v2, Lcom/inmobi/commons/internal/ThinICEConfig;->c:J

    long-to-int v2, v2

    mul-int/lit16 v2, v2, 0x3e8

    invoke-direct {v0, v1, v2}, Lcom/inmobi/commons/cache/RetryMechanism;-><init>(II)V

    .line 134
    new-instance v1, Lcom/inmobi/commons/internal/JSONPayloadCreator;

    invoke-direct {v1}, Lcom/inmobi/commons/internal/JSONPayloadCreator;-><init>()V

    .line 135
    invoke-static {}, Lcom/inmobi/commons/internal/InternalSDKUtil;->getContext()Landroid/content/Context;

    move-result-object v2

    invoke-virtual {v1, p0, v2}, Lcom/inmobi/commons/internal/JSONPayloadCreator;->toPayloadString(Ljava/util/List;Landroid/content/Context;)Ljava/lang/String;

    move-result-object v1

    .line 136
    const-string v2, "IMCOMMONS_3.7.0"

    new-instance v3, Ljava/lang/StringBuilder;

    invoke-direct {v3}, Ljava/lang/StringBuilder;-><init>()V

    const-string v4, "Sending "

    invoke-virtual {v3, v4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v3

    invoke-interface {p0}, Ljava/util/List;->size()I

    move-result v4

    invoke-virtual {v3, v4}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;

    move-result-object v3

    const-string v4, " ThinICE params to server"

    invoke-virtual {v3, v4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v3

    invoke-virtual {v3}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v3

    invoke-static {v2, v3}, Lcom/inmobi/commons/internal/Log;->internal(Ljava/lang/String;Ljava/lang/String;)V

    .line 137
    new-instance v2, Lcom/inmobi/commons/internal/ThinICE$a;

    invoke-direct {v2, v1}, Lcom/inmobi/commons/internal/ThinICE$a;-><init>(Ljava/lang/String;)V

    invoke-virtual {v0, v2}, Lcom/inmobi/commons/cache/RetryMechanism;->rescheduleTimer(Lcom/inmobi/commons/cache/RetryMechanism$RetryRunnable;)V

    goto :goto_0
.end method

.method public static start(Landroid/app/Activity;)V
    .locals 2
    .parameter

    .prologue
    .line 54
    invoke-static {p0}, Lcom/inmobi/commons/internal/ThinICE;->a(Landroid/app/Activity;)V

    .line 55
    sget v0, Landroid/os/Build$VERSION;->SDK_INT:I

    const/16 v1, 0xe

    if-ge v0, v1, :cond_0

    .line 56
    invoke-static {p0}, Lcom/inmobi/commons/thinICE/icedatacollector/IceDataCollector;->start(Landroid/content/Context;)V

    .line 58
    :cond_0
    return-void
.end method

.method public static stop(Landroid/app/Activity;)V
    .locals 2
    .parameter

    .prologue
    .line 61
    invoke-static {p0}, Lcom/inmobi/commons/internal/ThinICE;->a(Landroid/app/Activity;)V

    .line 62
    sget v0, Landroid/os/Build$VERSION;->SDK_INT:I

    const/16 v1, 0xe

    if-ge v0, v1, :cond_0

    .line 63
    invoke-static {}, Lcom/inmobi/commons/internal/ThinICE;->b()V

    .line 65
    :cond_0
    return-void
.end method
